package visiopuce.DAO;

import java.math.BigDecimal;
import java.util.List;

import org.hibernate.Query;

import visiopuce.HibernateUtil;
import visiopuce.objets.RenduBiomol;

public class RenduBiomolDAOImpl extends GenericDAOImpl<RenduBiomol, BigDecimal> implements RenduBiomolDAO {
	/** Constructeur priv� */
	private RenduBiomolDAOImpl() {
	}

	/** Instance unique non pr�initialis�e */
	private static RenduBiomolDAOImpl INSTANCE = null;

	/** Point d'acc�s pour l'instance unique du singleton */
	public static RenduBiomolDAO getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new RenduBiomolDAOImpl();
		}
		return INSTANCE;
	}

	@Override
	public List<RenduBiomol> getResultatqPCRByIdPuce(Integer idPuce) {

		List<RenduBiomol> resultats = null;
		String sql = "SELECT r FROM RenduBiomol r WHERE r.puce.idPuce = :idPuce order by r.idRenduBioMol";
		Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idPuce", idPuce);
		resultats = findMany(query);
	
		return resultats;

	}

	@Override
	public RenduBiomol getRenduBioMolByIdResultat(int idResultat) {
		RenduBiomol rendu = null;
		String sql = "SELECT r FROM RenduBiomol r WHERE r.resultat.idResultat = :idResultat";
		Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idResultat", idResultat);
		rendu = findOne(query);
		return rendu;
	}

}